package com.model;

import java.text.SimpleDateFormat;

public class SaleOrderNo {
	private String firstN;
	private String secondN;
	private String thirdN;

	public SaleOrderNo() {
		super();
	}

	public SaleOrderNo(String firstN, String secondN, String thirdN) {
		super();
		this.firstN = firstN;
		this.secondN = secondN;
		this.thirdN = thirdN;
	}

	public String getSaleOrder(String str, int i) {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
		String firstN = str;
		String secondN = sdf.format(System.currentTimeMillis());
		String thridN = String.format("%04d", i);
		String saleOrderNo = firstN + "-" + secondN + "-" + thridN;
		return saleOrderNo;
	}

	public String getFirstN() {
		return firstN;
	}

	public void setFirstN(String firstN) {
		this.firstN = firstN;
	}

	public String getSencondN() {
		return secondN;
	}

	public void setSencondN(String sencondN) {
		this.secondN = sencondN;
	}

	public String getThirdN() {
		return thirdN;
	}

	public void setThirdN(String thirdN) {
		this.thirdN = thirdN;
	}

	@Override
	public String toString() {
		return "SaleOrderN [firstN=" + firstN + ", sencondN=" + secondN
				+ ", thirdN=" + thirdN + "]";
	}

	public static void main(String[] args) {
		System.out.println(new SaleOrderNo().getSaleOrder("so", 2));
		SaleOrderNo saleOrderNo = new SaleOrderNo();
		saleOrderNo.setFirstN("SaleOrder");
		saleOrderNo.setSencondN("123");
//		saleOrderNo.setThirdN("123");
		for(int i=1;i<10;i++){
			saleOrderNo.setThirdN(String.format("%04d", i));
			System.out.println(saleOrderNo.firstN + "-" + saleOrderNo.secondN + "-"
					+ saleOrderNo.thirdN);
		}
		
	}
}
